package com.ruoyi.datam.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.base.datam.CmDeviceB;
import com.ruoyi.datam.mapper.CmDeviceBMapper;
import com.ruoyi.datam.service.ICmDeviceBService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 监测设备信息记录Service业务层处理
 *
 * @author hwd
 * @date 2023-02-21
 */
@Service
public class CmDeviceBServiceImpl implements ICmDeviceBService
{
    @Autowired
    private CmDeviceBMapper cmDeviceBMapper;

    /**
     * 查询监测设备信息记录
     *
     * @param devCd 监测设备信息记录主键
     * @return 监测设备信息记录
     */
    @Override
    public CmDeviceB selectCmDeviceBByDevCd(String devCd)
    {
        return cmDeviceBMapper.selectCmDeviceBByDevCd(devCd);
    }

    /**
     * 查询监测设备信息记录列表
     *
     * @param cmDeviceB 监测设备信息记录
     * @return 监测设备信息记录
     */
    @Override
    public List<CmDeviceB> selectCmDeviceBList(CmDeviceB cmDeviceB)
    {
        return cmDeviceBMapper.selectCmDeviceBList(cmDeviceB);
    }

    /**
     * 新增监测设备信息记录
     *
     * @param cmDeviceB 监测设备信息记录
     * @return 结果
     */
    @Override
    public int insertCmDeviceB(CmDeviceB cmDeviceB)
    {
       Integer count= cmDeviceBMapper.selectAllCmDeviceBList(new CmDeviceB()).size()+1;
       String xh=count.toString();
       if (count<10){
           xh="000"+count;
       }else if (count<100){
           xh="00"+count;
       }else if (count<1000){
           xh="0"+count;
       }
        cmDeviceB.setDevCd("DEV654322"+xh);
        return cmDeviceBMapper.insertCmDeviceB(cmDeviceB);
    }

    /**
     * 修改监测设备信息记录
     *
     * @param cmDeviceB 监测设备信息记录
     * @return 结果
     */
    @Override
    public int updateCmDeviceB(CmDeviceB cmDeviceB)
    {
        return cmDeviceBMapper.updateCmDeviceB(cmDeviceB);
    }

    /**
     * 批量删除监测设备信息记录
     *
     * @param devCds 需要删除的监测设备信息记录主键
     * @return 结果
     */
    @Override
    public int deleteCmDeviceBByDevCds(String[] devCds)
    {
        return cmDeviceBMapper.deleteCmDeviceBByDevCds(devCds);
    }

    /**
     * 删除监测设备信息记录信息
     *
     * @param devCd 监测设备信息记录主键
     * @return 结果
     */
    @Override
    public int deleteCmDeviceBByDevCd(String devCd)
    {
        return cmDeviceBMapper.deleteCmDeviceBByDevCd(devCd);
    }
    public List<CmDeviceB> selectCmDeviceBListByType(String[] statType) {
        return cmDeviceBMapper.selectCmDeviceBListByType(statType);
    }
}
